package com.jz.algorithm.Fibonacci;

import com.jz.algorithm.Sort.Sort;

import java.util.Collection;
import java.util.Collections;

/**
 * @ClassName : Fibonacci
 * @Description : 斐波那契数列
 * @Author : becky
 * @Date: 2021/9/1  13:32
 */
public class Fibonacci {

    /**
    * @Param : 求第n个斐波那契数列的值
    * @Description :  递归求斐波那契数列的某个值
    * @Author : Jz
    * @Date :   2021/09/01
    * @return   返回第n个值
    * @throws   null
    */

    public  static  int calculateNthValue(int n){

        if (n==1 || n==0){
            return n;
        }
        return calculateNthValue(n-1)+calculateNthValue(n-2);

    }
    /**
    * @Param : 求第n个斐波那契数列的值
    * @Description : 迭代求斐波那契数列的某个值
    * @Author : Jz
    * @Date :   2021/09/01
    * @return   返回第n个值
    * @throws   null
    */
    public static int fib(int n) {
        int a = 0, b = 1, sum;
        for(int i = 0; i < n; i++){
            sum = (a + b) % 1000000007;
            a = b;
            b = sum;
        }
        return a;
    }


    public static void main(String[] args) {
       int [] a={1,2,3,5,4,89,20,56,42};


       // System.out.println(22 %25);
    }
}
